<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #canvas {

            border: 1px solid #333;
        }
    </style>
</head>

<body>
    <canvas id="canvas" width="200" height="200"></canvas>
    <script>
        /* 1、获取canvas */
        let canvas = document.getElementById("canvas");
        /* 2、获取 绘制上下文   */
        let ctx = canvas.getContext("2d");
        /* 设置绘制的颜色 */
        ctx.fillStyle = "#652e80"  //需要先设置画布的颜色
        /* 1-2参数 x,y 
        3-4  width,height
         */
        ctx.fillRect(50, 50, 80, 100)


    </script>
</body>

</html>